using System;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Way.EntityDB.Attributes;
using System.Diagnostics.CodeAnalysis;

namespace CheckIn.ToolsHost.DBModels
{
    /// <summary>算命记录</summary>
    [TableConfig]
    [Table("fortunehistory")]
    [Way.EntityDB.DataItemJsonConverter]
    public partial class FortuneHistory :Way.EntityDB.DataItem
    {
        System.Nullable<Int64> _id;
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DisallowNull]
        [DesignColumn(TypeName = "bigint")]
        [Column("id")]
        public virtual System.Nullable<Int64> id
        {
            get
            {
                return _id;
            }
            set
            {
                if ((_id != value))
                {
                    SendPropertyChanging("id",_id,value);
                    _id = value;
                    SendPropertyChanged("id");
                }
            }
        }
        string? _Xing;
        /// <summary>姓氏</summary>
        [MaxLength(50)]
        [Display(Name = "姓氏")]
        [DesignColumn(TypeName = "varchar")]
        [Column("xing")]
        public virtual string? Xing
        {
            get
            {
                return _Xing;
            }
            set
            {
                if ((_Xing != value))
                {
                    SendPropertyChanging("Xing",_Xing,value);
                    _Xing = value;
                    SendPropertyChanged("Xing");
                }
            }
        }
        string? _Ming;
        /// <summary>名字</summary>
        [MaxLength(50)]
        [Display(Name = "名字")]
        [DesignColumn(TypeName = "varchar")]
        [Column("ming")]
        public virtual string? Ming
        {
            get
            {
                return _Ming;
            }
            set
            {
                if ((_Ming != value))
                {
                    SendPropertyChanging("Ming",_Ming,value);
                    _Ming = value;
                    SendPropertyChanged("Ming");
                }
            }
        }
        System.Nullable<DateTime> _Birthday;
        /// <summary>出生时间</summary>
        [Display(Name = "出生时间")]
        [DesignColumn(TypeName = "datetime")]
        [Column("birthday")]
        public virtual System.Nullable<DateTime> Birthday
        {
            get
            {
                return _Birthday;
            }
            set
            {
                if ((_Birthday != value))
                {
                    SendPropertyChanging("Birthday",_Birthday,value);
                    _Birthday = value;
                    SendPropertyChanged("Birthday");
                }
            }
        }
        string? _Sex;
        /// <summary>性别</summary>
        [MaxLength(10)]
        [Display(Name = "性别")]
        [DesignColumn(TypeName = "varchar")]
        [Column("sex")]
        public virtual string? Sex
        {
            get
            {
                return _Sex;
            }
            set
            {
                if ((_Sex != value))
                {
                    SendPropertyChanging("Sex",_Sex,value);
                    _Sex = value;
                    SendPropertyChanged("Sex");
                }
            }
        }
        string? _MonthDiZhi;
        /// <summary>月份地支</summary>
        [MaxLength(50)]
        [Display(Name = "月份地支")]
        [DesignColumn(TypeName = "varchar")]
        [Column("monthdizhi")]
        public virtual string? MonthDiZhi
        {
            get
            {
                return _MonthDiZhi;
            }
            set
            {
                if ((_MonthDiZhi != value))
                {
                    SendPropertyChanging("MonthDiZhi",_MonthDiZhi,value);
                    _MonthDiZhi = value;
                    SendPropertyChanged("MonthDiZhi");
                }
            }
        }
        string? _MonthFiveEle;
        /// <summary>月份五行</summary>
        [MaxLength(50)]
        [Display(Name = "月份五行")]
        [DesignColumn(TypeName = "varchar")]
        [Column("monthfiveele")]
        public virtual string? MonthFiveEle
        {
            get
            {
                return _MonthFiveEle;
            }
            set
            {
                if ((_MonthFiveEle != value))
                {
                    SendPropertyChanging("MonthFiveEle",_MonthFiveEle,value);
                    _MonthFiveEle = value;
                    SendPropertyChanged("MonthFiveEle");
                }
            }
        }
        System.Nullable<Int32> _TiangeCount;
        /// <summary>天格笔画数</summary>
        [Display(Name = "天格笔画数")]
        [DesignColumn(TypeName = "int")]
        [Column("tiangecount")]
        public virtual System.Nullable<Int32> TiangeCount
        {
            get
            {
                return _TiangeCount;
            }
            set
            {
                if ((_TiangeCount != value))
                {
                    SendPropertyChanging("TiangeCount",_TiangeCount,value);
                    _TiangeCount = value;
                    SendPropertyChanged("TiangeCount");
                }
            }
        }
        string? _TiangeFive;
        /// <summary>天格五行</summary>
        [MaxLength(50)]
        [Display(Name = "天格五行")]
        [DesignColumn(TypeName = "varchar")]
        [Column("tiangefive")]
        public virtual string? TiangeFive
        {
            get
            {
                return _TiangeFive;
            }
            set
            {
                if ((_TiangeFive != value))
                {
                    SendPropertyChanging("TiangeFive",_TiangeFive,value);
                    _TiangeFive = value;
                    SendPropertyChanged("TiangeFive");
                }
            }
        }
        string? _TiangeResult;
        /// <summary>天格卦辞</summary>
        [MaxLength(255)]
        [Display(Name = "天格卦辞")]
        [DesignColumn(TypeName = "varchar")]
        [Column("tiangeresult")]
        public virtual string? TiangeResult
        {
            get
            {
                return _TiangeResult;
            }
            set
            {
                if ((_TiangeResult != value))
                {
                    SendPropertyChanging("TiangeResult",_TiangeResult,value);
                    _TiangeResult = value;
                    SendPropertyChanged("TiangeResult");
                }
            }
        }
        System.Nullable<Int32> _RengeCount;
        /// <summary>人格笔画数</summary>
        [Display(Name = "人格笔画数")]
        [DesignColumn(TypeName = "int")]
        [Column("rengecount")]
        public virtual System.Nullable<Int32> RengeCount
        {
            get
            {
                return _RengeCount;
            }
            set
            {
                if ((_RengeCount != value))
                {
                    SendPropertyChanging("RengeCount",_RengeCount,value);
                    _RengeCount = value;
                    SendPropertyChanged("RengeCount");
                }
            }
        }
        string? _RengeFive;
        /// <summary>人格五行</summary>
        [MaxLength(50)]
        [Display(Name = "人格五行")]
        [DesignColumn(TypeName = "varchar")]
        [Column("rengefive")]
        public virtual string? RengeFive
        {
            get
            {
                return _RengeFive;
            }
            set
            {
                if ((_RengeFive != value))
                {
                    SendPropertyChanging("RengeFive",_RengeFive,value);
                    _RengeFive = value;
                    SendPropertyChanged("RengeFive");
                }
            }
        }
        string? _RengeResult;
        /// <summary>人格卦辞</summary>
        [MaxLength(255)]
        [Display(Name = "人格卦辞")]
        [DesignColumn(TypeName = "varchar")]
        [Column("rengeresult")]
        public virtual string? RengeResult
        {
            get
            {
                return _RengeResult;
            }
            set
            {
                if ((_RengeResult != value))
                {
                    SendPropertyChanging("RengeResult",_RengeResult,value);
                    _RengeResult = value;
                    SendPropertyChanged("RengeResult");
                }
            }
        }
        System.Nullable<Int32> _DigeCount;
        /// <summary>地格笔画数</summary>
        [Display(Name = "地格笔画数")]
        [DesignColumn(TypeName = "int")]
        [Column("digecount")]
        public virtual System.Nullable<Int32> DigeCount
        {
            get
            {
                return _DigeCount;
            }
            set
            {
                if ((_DigeCount != value))
                {
                    SendPropertyChanging("DigeCount",_DigeCount,value);
                    _DigeCount = value;
                    SendPropertyChanged("DigeCount");
                }
            }
        }
        string? _DigeFive;
        /// <summary>地格五行</summary>
        [MaxLength(50)]
        [Display(Name = "地格五行")]
        [DesignColumn(TypeName = "varchar")]
        [Column("digefive")]
        public virtual string? DigeFive
        {
            get
            {
                return _DigeFive;
            }
            set
            {
                if ((_DigeFive != value))
                {
                    SendPropertyChanging("DigeFive",_DigeFive,value);
                    _DigeFive = value;
                    SendPropertyChanged("DigeFive");
                }
            }
        }
        string? _DigeResult;
        /// <summary>地格卦辞</summary>
        [MaxLength(255)]
        [Display(Name = "地格卦辞")]
        [DesignColumn(TypeName = "varchar")]
        [Column("digeresult")]
        public virtual string? DigeResult
        {
            get
            {
                return _DigeResult;
            }
            set
            {
                if ((_DigeResult != value))
                {
                    SendPropertyChanging("DigeResult",_DigeResult,value);
                    _DigeResult = value;
                    SendPropertyChanged("DigeResult");
                }
            }
        }
        System.Nullable<Int32> _WaigeCount;
        /// <summary>外格笔画数</summary>
        [Display(Name = "外格笔画数")]
        [DesignColumn(TypeName = "int")]
        [Column("waigecount")]
        public virtual System.Nullable<Int32> WaigeCount
        {
            get
            {
                return _WaigeCount;
            }
            set
            {
                if ((_WaigeCount != value))
                {
                    SendPropertyChanging("WaigeCount",_WaigeCount,value);
                    _WaigeCount = value;
                    SendPropertyChanged("WaigeCount");
                }
            }
        }
        string? _WaigeFive;
        /// <summary>外格五行</summary>
        [MaxLength(50)]
        [Display(Name = "外格五行")]
        [DesignColumn(TypeName = "varchar")]
        [Column("waigefive")]
        public virtual string? WaigeFive
        {
            get
            {
                return _WaigeFive;
            }
            set
            {
                if ((_WaigeFive != value))
                {
                    SendPropertyChanging("WaigeFive",_WaigeFive,value);
                    _WaigeFive = value;
                    SendPropertyChanged("WaigeFive");
                }
            }
        }
        string? _WaigeResult;
        /// <summary>外格卦辞</summary>
        [MaxLength(255)]
        [Display(Name = "外格卦辞")]
        [DesignColumn(TypeName = "varchar")]
        [Column("waigeresult")]
        public virtual string? WaigeResult
        {
            get
            {
                return _WaigeResult;
            }
            set
            {
                if ((_WaigeResult != value))
                {
                    SendPropertyChanging("WaigeResult",_WaigeResult,value);
                    _WaigeResult = value;
                    SendPropertyChanged("WaigeResult");
                }
            }
        }
        System.Nullable<Int32> _ZonggeCount;
        /// <summary>总格笔画数</summary>
        [Display(Name = "总格笔画数")]
        [DesignColumn(TypeName = "int")]
        [Column("zonggecount")]
        public virtual System.Nullable<Int32> ZonggeCount
        {
            get
            {
                return _ZonggeCount;
            }
            set
            {
                if ((_ZonggeCount != value))
                {
                    SendPropertyChanging("ZonggeCount",_ZonggeCount,value);
                    _ZonggeCount = value;
                    SendPropertyChanged("ZonggeCount");
                }
            }
        }
        string? _ZonggeFive;
        /// <summary>总格五行</summary>
        [MaxLength(50)]
        [Display(Name = "总格五行")]
        [DesignColumn(TypeName = "varchar")]
        [Column("zonggefive")]
        public virtual string? ZonggeFive
        {
            get
            {
                return _ZonggeFive;
            }
            set
            {
                if ((_ZonggeFive != value))
                {
                    SendPropertyChanging("ZonggeFive",_ZonggeFive,value);
                    _ZonggeFive = value;
                    SendPropertyChanged("ZonggeFive");
                }
            }
        }
        string? _ZonggeResult;
        /// <summary>总格卦辞</summary>
        [MaxLength(255)]
        [Display(Name = "总格卦辞")]
        [DesignColumn(TypeName = "varchar")]
        [Column("zonggeresult")]
        public virtual string? ZonggeResult
        {
            get
            {
                return _ZonggeResult;
            }
            set
            {
                if ((_ZonggeResult != value))
                {
                    SendPropertyChanging("ZonggeResult",_ZonggeResult,value);
                    _ZonggeResult = value;
                    SendPropertyChanged("ZonggeResult");
                }
            }
        }
        /// <summary>把字段的更新，设置为一个指定的表达式值</summary>
        /// <param>指定的更新表达式，如 m=&gt;m.age == m.age + 1 &amp;&amp; name == name + "aa"，相当于sql语句的 age=age+1,name=name + 'aa'</param>
         public virtual void SetValue(System.Linq.Expressions.Expression<Func<FortuneHistory, bool>> exp)
        {
            base.SetValue<FortuneHistory>(exp);
        }
    }
}

namespace CheckIn.ToolsHost.DBModels.DB
{
    public class CheckInTools : Way.EntityDB.DBContext
    {
         public CheckInTools(string connection, Way.EntityDB.DatabaseType dbType , bool upgradeDatabase = true): base(connection, dbType , upgradeDatabase)
        {
            if (!setEvented)
            {
                lock (lockObj)
                {
                    if (!setEvented)
                    {
                        setEvented = true;
                        Way.EntityDB.DBContext.BeforeDelete += Database_BeforeDelete;
                    }
                }
            }
        }
        static object lockObj = new object();
        static bool setEvented = false;
        static void Database_BeforeDelete(object sender, Way.EntityDB.DatabaseModifyEventArg e)
        {
             var db =  sender as CheckInTools;
            if (db == null) return;
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<FortuneHistory>().HasKey(m => m.id);
        }
        System.Linq.IQueryable<FortuneHistory> _FortuneHistory;
        /// <summary>算命记录</summary>
        public virtual System.Linq.IQueryable<FortuneHistory> FortuneHistory
        {
            get
            {
                if (_FortuneHistory == null)
                {
                    _FortuneHistory = this.Set<FortuneHistory>();
                }
                return _FortuneHistory;
            }
        }
        protected override string GetDesignString()
        {
            var result = new StringBuilder();
            result.Append("\r\n");
            result.Append("H4sIAAAAAAAAA92ZTU8TQRjHv8uewXS3L7TcsIXYqIRQVILlMN2dthO3s7g7ixJCwk0OEjUWuBBfEiIxKnIwHor4aWjBb+G8LHR3uk0EJyHLqTPPvP92/tv951nV5kDNhp42/nhVFKdBC2rj2ozjkYYLK09tbUSbdZ6JHmUCW6IUdEMWbX4IbJ9W9LWRizhZWYL9Fq3o");
            result.Append("QkAgn3/CJMjBWqiv6WACMQl1X62KvVS1cVpEFv3Vs7mRqmaCJTaa1qva6cFO983x2cFh93irqtFGNh1vmXJc4mN4B3nEcVd4WwkQUAMeLJfYXAUaQfcc8wmtpNZopejYfgt7VXa08wXzeiqyIvZtO7wK60XrZW/CJ04Zmy5s0VPQJuL6kM0J8DQdQgN1YHssYtXmKBY+");
            result.Append("uIYaiHWm0SAWTD+J/VYJ1hEOxWyIG6TZr1uwDnybcFr9KCcmzsdZlb2Zu7wa7MdxLejyo6V4awl5potaCANKKbTLog08LzhlMDUPTdFyKEwfYJ+ULj2b7v7b3uGr6FOZR7gxhNjF0hfIgj2HiC0D12wC97LIqlo2xcdcEtr5lvrUdOXUDJna683ut50otfsJp2Yop5aW");
            result.Append("qb3onLbf93Z+/tn5EWV3G7mkaYGV/+Bn0dcWQWy+ywJUgy+tHF9Gwtdb3+9ufImCq8Dn13HndEV3LqMcWlaGtrtxcnTc3T3stb9LeqV/Zs0SWmiiJKs2q5yg/O8tCJ502mcfX8YQnELLcNKGSWaYU85wTH7z7X3uffh1+rV92j7qbR1GMc4hgBuw6PjBZ8bVKF7hI0XV");
            result.Append("q29MOb98LL+4OyjgsUuY5BuYV06wEEuwu/np7Pe7OIKz0KMnuA6GRjarBmJBNUQjJUE86XSGy3gWJlvFunKzYchmQ/CLkzGHl3QV68qNhyEbD0EwTsac4A1Qsa7chxgDPoR+DQ6VcQklW8XKfYgh+xCBL07FjF3iRazckxiyJxEA40TMAN4EDSt3JYbsSrp728M1/Agk");
            result.Append("XMTKHYkx6Ei2h4iYw0u8ipV7EmPQk2wPUTEneBNkrNyWGLIt6a0fDZfxgoMbydaxckuSli2JABinY0Ev6UI2lLuStOxKBMI4IQuEN0DJhhpnsshmKc0XHVxHDZ6DE5GqyFQ98KBb5pDXwllDK8joRTKQBToZy1ZWCCCQ5fZoNcjt8aylKIdzlywxyOjRemXFI7B1q4xJ");
            result.Append("LsNXivQOMpqD/SvERbgxOKCf1vz3MZFDDd3aIjsWa61AEgwE9bRZSNfro3lo5kYzVr4wms8WaCln1WFKh5nCWFZb+wtmdxmL7h0AA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